<template>
  <div class="home-big-box">
    <div class="home-top-nav-box">
      <div class="home-top-left-box">
        <div v-if="!userAvatar" class="home-top-left-name">
          {{initName( userName)}}
        </div>
        <div v-else class="home-top-left-name">
          <img :src="userAvatar">
        </div>
        <div class="home-top-left-tit">
          报名人数查询
        </div>
      </div>
    </div>
    <!-- 主体部分 -->
    <div class="big-main-box">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  name: "home",
  data() {
    return {
      userName: localStorage.getItem("userName"),
      userAvatar: localStorage.getItem("userAvatar")
    };
  },
  created() {
    this.$router.push({
      name: "table"
    });
  },
  methods: {
    // 初始化姓名
    initName(name) {
      if (!name) {
        return "";
      } else if (name.length < 3) {
        return name;
      } else {
        return name.substring(name.length - 2);
      }
    }
  }
};
</script>

<style scoped>
.home-big-box {
  width: 100%;
  height: auto;
}
.home-top-nav-box {
  width: 100%;
  height: auto;
  position: fixed;
  left: 0px;
  top: 0px;
  background-color: #545c64;
  overflow: hidden;
  z-index: 999;
  /* border: 1px solid red; */
}
.home-top-left-box {
  float: left;
  margin-left: 60px;
  width: auto;
  height: 100%;
  display: flex;
  -webkit-display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 8px;
}
.home-top-left-name {
  width: 46px;
  height: 46px;
  line-height: 46px;
  border-radius: 46px;
  color: #fff;
  background: #383637;
  overflow: hidden;
}
.home-top-left-name > img {
  width: 100%;
  height: auto;
}
.home-top-left-tit {
  margin-left: 10px;
  color: #fff;
  font-size: 18px;
}
.big-main-box {
  width: 100%;
  height: auto;
  /* border: 1px solid red; */
  margin-top: 70px;
  padding: 0px 16px 36px 16px;
  text-align: left;
}
</style>
